package com.zlz.blog.server.show;

import com.zlz.blog.manage.common.entity.blog.Blog;
import com.zlz.blog.manage.common.entity.category.Category;
import com.zlz.blog.manage.common.entity.tag.Tag;
import com.zlz.blog.manage.common.response.PageInfo;
import com.zlz.blog.manage.common.response.ResultSet;
import com.zlz.blog.manage.common.vos.blog.BlogVO;
import com.zlz.blog.server.blog.service.BlogService;
import com.zlz.blog.server.category.service.CategoryService;
import com.zlz.blog.server.tag.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 博客文章查询展示
 *
 * @author wb_zhulinzhong
 * @date 2021-06-08 11:46:21
 */
@RestController
@RequestMapping("/show")
public class ShowController {

    private BlogService blogService;
    private CategoryService categoryService;
    private TagService tagService;

    @Autowired
    public void setBlogService(BlogService blogService){
        this.blogService = blogService;
    }
    @Autowired
    public void setCategoryService(CategoryService categoryService){
        this.categoryService = categoryService;
    }
    @Autowired
    public void setTagService(TagService tagService){
        this.tagService = tagService;
    }

    /**
     * 分页查询,模糊查询
     * @param blog blog
     * @param request request
     * @return ResultSet
     */
    @PostMapping("/blog/query/pagelist")
    public ResultSet<PageInfo<Blog>> selectAll(@RequestBody BlogVO blog, HttpServletRequest request) {
        return blogService.selectList(blog, request, true);
    }

    /**
     * 查询所有文章分类
     * @param category
     * @return
     */
    @PostMapping("/category/query/list")
    public ResultSet<List<Category>> getList(@RequestBody(required = false) Category category){
        return categoryService.getListForShow(category);
    }

    /**
     * 查询标签列表
     * @param tag
     * @return
     */
    @PostMapping("/tag/query/list")
    public ResultSet<List<Tag>> queryTagList(@RequestBody Tag tag){
        return tagService.queryTagListForShow(tag);
    }

    /**
     * 查询推荐的文章列表
     * @return
     */
    @GetMapping("/recommend/query/list")
    public ResultSet queryRecommendList(){
        return null;
    }

    /**
     * 查询热门的文章列表
     * @return
     */
    @GetMapping("/hot/query/list")
    public ResultSet queryHotList(){
        return null;
    }
}
